package cn.xmstore.service.impl;

import cn.xmstore.globals.BusinessCode;
import cn.xmstore.service.CheckCodeService;
import cn.xmstore.util.CheckCodeUtil;
import cn.xmstore.util.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

/**
 * @author： Aeolia
 * @Description： TODO
 * @Date： 2021/9/2 14:14
 */
@Service("checkCodeService")
public class CheckCodeServiceImpl implements CheckCodeService {
    @Autowired
    private CheckCodeUtil checkCodeUtil;
    @Autowired
    @Qualifier(value = "redisUtil")
    private RedisUtil<String, String, String> redisUtil;

    @Override
    public void register(String phoneNum) {
        //调用工具类生成验证码
        String checkCode = checkCodeUtil.createCheckCode();
        //调用第三方短信发送接口
        //根据业务和参数生成存入redis所需的objKey和key
        String key = phoneNum;

        //存入redis
        redisUtil.add(BusinessCode.REGISTER.getCode()+phoneNum, checkCode, 300);

    }

    @Override
    public void register(String phoneNum, long time) {
        //根据业务和参数生成存入redis所需的objKey和key

        //调用工具类生成验证码
        String checkCode = checkCodeUtil.createCheckCode();
        //调用第三方短信发送接口

        //存入redis
        redisUtil.add(BusinessCode.REGISTER.getCode()+phoneNum, checkCode, time);
    }

    @Override
    public String getCheckCode(Object objectKey, Object key) {
        return null;
    }

    @Override
    public String getCheckCode(Object key) {
        return null;
    }

    @Override
    public boolean verify(String checkCode, String genericCode) {
        return false;
    }
}
